﻿<%@ WebHandler Language="C#" Class="login" %>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

public class login : IHttpHandler, IRequiresSessionState
{
    sqlhelp sql = new sqlhelp();
    result result = new result();
    
    public void ProcessRequest (HttpContext context) {
        if (context.Request["username"] != null && context.Request["pwd"] != null)
        {
            string username = context.Request["username"].ToString();
            string pwd = context.Request["pwd"].ToString();

            string str = "select Id from SYS_Store where UserName = '" + username + "' and PassWord = '" + pwd + "' ";
            //验证用户名  密码
            System.Data.DataTable dt = sql.myDataSet(str).Tables[0];
            if (dt.Rows.Count > 0)
            {
                result.code = "1";
                result.msg = "";
                context.Session["comid"] = dt.Rows[0]["Id"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "用户名或密码不正确";
            }

        }
        else
        {
            result.code = "0";
            result.msg = "未传递用户名密码";
        }
        unit.send(context, result);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}